import api from './index'
import config from "@/config"

export const getOrgTreeApi = (parentId) => {
    const url = `${config.pre}/item-pool/org/tree/${parentId}`
    return api.get(url)
}

export const getOrgTreeByUserApi = (params) => {
    const url = `${config.pre}/item-pool/org/tree/byUser`
    return api.post(url, params)
}

export const getTenantsByIdApi = (orgId) => {
    const url = `${config.pre}/item-pool/pool/tenant/${orgId}`
    return api.get(url)
}

export const orgGoodsListApi = (params) => {
    const url = `${config.pre}/item-pool/pool/list?pageNum=${params.pageNum}&pageSize=${params.pageSize}`
    return api.post(url, params)
}

export const deleteGoodsApi = (id) => {
    const url = `${config.pre}/item-pool/pool/delete/${id}`
    return api.delete(url)
}

export const addGoodsApi = (orgId, params) => {
    const url = `${config.pre}/item-pool/pool/add/${orgId}`
    return api.post(url, params)
}

export const updateGoodsApi = (params) => {
    const url = `${config.pre}/item-pool/pool/update`
    return api.put(url, params)
}

export const getTenantInfoByUserApi = (params) => {
    const url = `${config.pre}/item-pool/tenant/info`
    return api.post(url, params)
}

export const bindCategoryApi = (orgId, params) => {
    const url = `${config.pre}/item-pool/pool/addCategory/${orgId}`
    return api.post(url, params)
}

export const batchDeletePoolApi = (params) => {
    const url = `${config.pre}/item-pool/pool/delete/more`
    return api.post(url, params)
}
/**
 * 价格模版接口
 */

export const priceTemplateListApi = (params) => {
    const url = `${config.pre}/item-pool/priceTemplate/list?pageNum=${params.pageNum}&pageSize=${params.pageSize}`
    return api.post(url, params)
}

export const deletePriceTemplateApi = (id) => {
    const url = `${config.pre}/item-pool/priceTemplate/delete/${id}`
    return api.delete(url)
}

export const addPriceTemplateApi = (params) => {
    const url = `${config.pre}/item-pool/priceTemplate/insert`
    return api.post(url, params)
}

export const updatePriceTemplateApi = (params) => {
    const url = `${config.pre}/item-pool/priceTemplate/update`
    return api.put(url, params)
}

export const selectTemplateApi = (id) => {
    const url = `${config.pre}/item-pool/priceTemplate/selectTemplate/${id}`
    return api.get(url)
}

/**
 * 系统商品上下架状态配置相关接口
 */
export const configListApi = (params) => {
    const url = `${config.pre}/item-pool/config/list?pageNum=${params.pageNum}&pageSize=${params.pageSize}`
    return api.post(url, params)
}

export const insertConfigApi = (params) => {
    const url = `${config.pre}/item-pool/config/add`
    return api.post(url, params)
}

export const updateConfigApi = (params) => {
    const url = `${config.pre}/item-pool/config/update`
    return api.put(url, params)
}

export const deleteConfigApi = (id) => {
    const url = `${config.pre}/item-pool/config/delete/${id}`
    return api.delete(url)
}


